// user的pinia仓库
import type { User } from '@/types/user'
import { defineStore } from 'pinia'
import { ref } from 'vue'

// 实现了持久化处理
export const useUserStore = defineStore(
  'user',
  () => {
    const uyUser = ref<User>()
    const setUserInfo = (u: User) => {
      uyUser.value = u
    }
    // 清空用户信息
    const deleteUserInfo = () => {
      uyUser.value = undefined
    }
    return { uyUser, setUserInfo, deleteUserInfo }
  },
  {
    persist: true
  }
)
